package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.model.UserModel;
import com.zr.service.LiveinDormService;

/**
 * 住宿信息的调配者
 * @author 洪英杰
 *
 */
public class LiveinDormController extends HttpServlet{
	LiveinDormService lds=new LiveinDormService();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//从session中获取学生的学号	
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		HttpSession session=req.getSession();		
		UserModel user1=(UserModel)session.getAttribute("usermodel");
		int sid=user1.getSid();
		
		//打印信息在页面相应的申请表中
		PrintWriter pw=resp.getWriter();
		pw.write(lds.dormInfo(sid).toString());
		
	}
}
